using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using DevExpress.XtraTreeList.Nodes;

using DevExpress.XtraEditors;
using System.Runtime.InteropServices;
using TierApplication;

namespace BasisMgr
{
    public partial class frmSectionSelct : TierService.frmTemplate
    {

        #region "Variable"
        public string gSectionID = "";
        public string ggSectionName = "";
        public string gDeptID = "";
        #endregion
        public frmSectionSelct()
        {
            InitializeComponent();
        }

        private void BindGrid()
        {
            string sWhere = "";
            if (gDeptID != "")
                sWhere = " and SectionID in (Select SectionID from P_Dept_Section where DeptID='" + gDeptID + "')";
            P_Section mSection = new P_Section();
            DataTable dtSection = mSection.GetList(sWhere).Tables[0];
            tlSection.DataSource = dtSection;
            tlSection.KeyFieldName = "SectionID";
            tlSection.ParentFieldName = "PrevSectionID";
            tlSection.ExpandAll();
        }

        private void btnQuit_Click(object sender, EventArgs e)
        {
            DialogResult = System.Windows.Forms.DialogResult.Cancel;
        }

        private void tlDept_DoubleClick(object sender, EventArgs e)
        {
            TreeListNode node = tlSection.FocusedNode;

            if (node != null)
            {
                gSectionID = node["SectionID"].ToString();
                ggSectionName = node["SectionName"].ToString();
                DialogResult = System.Windows.Forms.DialogResult.OK;
            }
        }

        private void btnModify_Click(object sender, EventArgs e)
        {
            TreeListNode node = tlSection.FocusedNode;

            if (node != null)
            {
                gSectionID = node["SectionID"].ToString();
                ggSectionName = node["SectionName"].ToString();
            }
            DialogResult = System.Windows.Forms.DialogResult.OK;
        }

        private void frmSectionSelct_Load(object sender, EventArgs e)
        {

            BindGrid();
        }

    }
}